package com.cn.jinl.controller;


import com.cn.jinl.api.IProcureCloseService;
import com.cn.jinl.domain.ProcureClose;
import com.cn.jinl.utils.CommonUtil;
import com.cn.jinl.utils.JsonResponse;
import com.cn.jinl.utils.QueryForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/procureClose")
public class ProcureCloseController {

    @Autowired
    private IProcureCloseService procureCloseService;


    @RequestMapping("/getProcureCloseList/{frontToken}")
    @ResponseBody
    public JsonResponse<List<ProcureClose>> getProcureCloseList(@PathVariable(value = "frontToken",required = true) String frontToken,String procureId) throws Exception{
        JsonResponse<List<ProcureClose>> response = new JsonResponse<>();
        List<ProcureClose> procures = procureCloseService.getProcureCloseList(procureId);
        response.setResult(procures);
        response.setSuccess(true);
        return response;
    }


    @RequestMapping("/addProcureClose/{frontToken}")
    @ResponseBody
    public JsonResponse<String> addProcureClose(ProcureClose procureClose, @PathVariable(value = "frontToken",required = true) String frontToken) throws Exception{
        JsonResponse<String> response = new JsonResponse<>();
        String result = procureCloseService.addProcureClose(procureClose);
        return CommonUtil.getResponseData(response,result);
    }


}
